<template>

      <div id="mainloginFrame">
        <div id="logincss">
          <h2 style="text-align: center">重置密码查询</h2>
          <el-form ref="form" label-width="100px">
          <el-form-item label="用户名：">
            <el-input  placeholder="请输入你的用户名:" v-model="userId">
            </el-input>
          </el-form-item>
          <el-form-item label="提取码：">
            <el-input   type="password" placeholder="请输入你的提取码（请求结果用）:" v-model="checkcode">
            </el-input>
          </el-form-item>
            <el-row style="text-align: center">
              <el-button @click="returnlogin">返回</el-button>
              <el-button @click="searchpassword">查询</el-button>
            </el-row>
          </el-form>
        </div>
    </div>
</template>

<script>
    export default {
        name: "searchpasswordView",
      data()
      {
        return{
          userId:"",
          checkcode:""
        }
      },
      methods:{
        returnlogin(){
          this.$router.push({path: '/'});
        },
        searchpassword()
        {
          if(this.userId == ""||this.checkcode == "")
          {
            this.userId = ""
            this.checkcode = ""
            return this.$message.error("用户名和提取码信息不全！")
          }
          this.$axios.post("/FindPassword",{
            userId:this.userId,
            checkcode:this.checkcode
          },{
            responseType: 'json'
          }).then((res)=>{
            this.$message.error(res.data)
                  if(res.data.msg == "noverify")
                  {
                    this.userId = ""
                    this.checkcode = ""
                    return this.$message.error("密码请求未审核通过或提取码错误！")
                  }
                  if((res.data.msg == "success"&&res.status == 200))
                  {
                    this.$axios.post("/getnewPassword",
                      {
                        userId:this.userId
                      },{
                        responseType: 'json'
                      }).then((res)=>{
                        alert("用户："+JSON.stringify(res.data.userId)+",你的初始密码已设置为："+JSON.stringify(res.data.password)+"，请尽快修改新密码！")
                        this.$router.push({path:"/"})
                      })

                  }
          })
        }
      }
    }
</script>

<style scoped>
  #mainloginFrame{
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #42b983;
  }
  #logincss{
    width: 350px;
    margin: 160px auto; /* 上下间距160px，左右自动居中*/
    background-color: rgb(255, 255, 255); /* 透明背景色 */
    padding: 30px;
    border-radius: 20px; /* 圆角 */
  }


  a:link {
    color: #330099;
    text-decoration: none;
  }
  a:visited {
    text-decoration: none;
  }
  a:hover {
    text-decoration: underline;
    color: #FF0000;
  }
  a:active {
    text-decoration: none;
  }
</style>
